#include "rename.h"
#include "traverse.h"
#include "tree_basic.h"
#include "dbug.h"
#include "memory.h"
#include "globals.h"
#include "str.h"

static info *MakeInfo()
{
  return NULL;
}


static info *FreeInfo( info *info)
{
  return NULL;
}

node *
RENAMEvarlet (node * arg_node, info * arg_info)
{
  DBUG_ENTER ("RENAMEvarlet");
  char *tmp = STRcat("__", VARLET_NAME( arg_node));
  free(VARLET_NAME( arg_node));

  VARLET_NAME( arg_node) = tmp;

  arg_node = TRAVcont(arg_node, arg_info);
  DBUG_RETURN (arg_node);
}

node *
RENAMEvar (node * arg_node, info * arg_info)
{
  DBUG_ENTER ("RENAMEvar");
  char *tmp = STRcat("__", VAR_NAME( arg_node));
  free(VAR_NAME( arg_node));

  VAR_NAME( arg_node) = tmp;

  arg_node = TRAVcont(arg_node, arg_info);
  DBUG_RETURN (arg_node);
}

node
*RENAMEdoRename( node *syntaxtree)
{
  info *info;

  DBUG_ENTER("RENAMEdoRename");

  DBUG_ASSERT( (syntaxtree!= NULL), "RENAMEdoRename called with empty syntaxtree");

  info = MakeInfo();

  TRAVpush( TR_rename);

  syntaxtree = TRAVdo( syntaxtree, info);

  TRAVpop();

  info = FreeInfo(info);

  DBUG_RETURN( syntaxtree);
}
